﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using leviathan.player;

namespace leviathan.combat
{
    public partial class Combat : Form
    {
        public CombatClass combatengine;
        private supervisor.Supervisor super;

        public Combat(Player p1, string mobnam, supervisor.Supervisor supv)
        {
            InitializeComponent();

            combatengine = new CombatClass(p1, mobnam, button1, button2, button3, output_combat, this);
            
            hpBar.Maximum = combatengine.getActHp();
            manaBar.Maximum = combatengine.getActMana();
            EnemyHpBar.Maximum = combatengine.getActEHp();
            EnemyManaBar.Maximum = combatengine.getActEMana();
            hpBar.Value = hpBar.Maximum;
            manaBar.Value = manaBar.Maximum;
            EnemyHpBar.Value = EnemyHpBar.Maximum;
            EnemyManaBar.Value = EnemyManaBar.Maximum;
            super = supv;

            this.Show();
        }

        private void Combat_Load(object sender, EventArgs e)
        {
            this.Visible = true;
            this.Activate();
            this.BringToFront();

            button1.Text = combatengine.getAttackMode1().name;
            button2.Text = combatengine.getAttackMode2().name;
            button3.Text = combatengine.getAttackMode3().name;
            output_combat.Text = "Egy " + combatengine.getEName() + " áll veled szemben. Készülj a harcra!";
        }

        private void autoMode_Click(object sender, EventArgs e)
        {
            combatengine.setAuto(true);
        }

        private void Button_Click(object sender, EventArgs e)
        {
            if (sender == button1)
            {
                combatengine.selectMode(1);

                hpBar.Value = combatengine.getActHp();
                manaBar.Value = combatengine.getActMana();
                EnemyHpBar.Value = combatengine.getActEHp();
                EnemyManaBar.Value = combatengine.getActEMana();

            }
            else if (sender == button2)
            {
                combatengine.selectMode(2);

                hpBar.Value = combatengine.getActHp();
                manaBar.Value = combatengine.getActMana();
                EnemyHpBar.Value = combatengine.getActEHp();
                EnemyManaBar.Value = combatengine.getActEMana();

            }
            else if(sender == button3)
            {
                combatengine.selectMode(3);

                hpBar.Value = combatengine.getActHp();
                manaBar.Value = combatengine.getActMana();
                EnemyHpBar.Value = combatengine.getActEHp();
                EnemyManaBar.Value = combatengine.getActEMana();


            }
            else if (sender == hpPotion)
            {
                combatengine.selectDrink(1);

                hpBar.Value = combatengine.getActHp();
                manaBar.Value = combatengine.getActMana();
                EnemyHpBar.Value = combatengine.getActEHp();
                EnemyManaBar.Value = combatengine.getActEMana();
            }
            else if (sender == manaPotion)
            {
                combatengine.selectDrink(2);

                hpBar.Value = combatengine.getActHp();
                manaBar.Value = combatengine.getActMana();
                EnemyHpBar.Value = combatengine.getActEHp();
                EnemyManaBar.Value = combatengine.getActEMana();
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            combatengine.commitSuicide();
        }

        private void Combat_FormClosing(object sender, FormClosingEventArgs e)
        {
            super.setCombatState(combatengine.getState());
            super.fight(combatengine.getXp());
        }
    }
}
